package com.sky.bridge;

import java.math.BigDecimal;

/**
 * @author : wushikai
 * <p>
 * date : 2020-08-12
 */

/*---------------桥接模式实例: 电脑商城------------------*/


class Brand {

    String brandName="";

}



class Computer{

    Brand brand;
    String name ;

}


class Desktop extends Computer{



    Desktop(Brand  brand){
        super.brand =brand;
        super.name = "台式机";
    }

    void  sale(BigDecimal price){

        System.out.println( "销售:"  + super.brand.brandName + super.name + "  价格  " + price);

    }

}


class LapTop extends Computer{

    LapTop(Brand  brand){
        this.brand =brand;

        super.name = "笔记本";
    }

    void  sale(BigDecimal price){

        System.out.println( "销售:"  + brand.brandName + name + "  价格  " + price);

    }

}


class Pad extends Computer{


    Pad(Brand  brand){
        super.brand =brand;
        super.name = "平板";
    }

    void  sale(BigDecimal price){

        System.out.println( "销售:"  + brand.brandName + name + "  价格  " + price);

    }


}



class Huawei extends Brand{


    Huawei() {
        super.brandName = "华为";
    }
}

class ShenChuan extends Brand{

    public ShenChuan() {
        super.brandName = "神船";
    }
}


class Lenovo extends Brand{

    public Lenovo () {
        super.brandName = "联想";
    }
}




public class ComputerMarket {


    private static void sale(){
        Brand huawei = new Huawei();
        Desktop huaweiDesktop = new Desktop(huawei);
        huaweiDesktop.sale(new BigDecimal("10000"));


        Lenovo lenovo = new Lenovo();
        Desktop lenovoDesktop= new Desktop(lenovo);
        lenovoDesktop.sale(new BigDecimal("3000"));


    }


    public static void main(String[] args){
        sale();
    }

}

/*-------------使用桥接模式, 111创建的类个数是 n + m + 2 --------------*/















